//
//  MonitorViewController.m
//  DevIPad
//
//  Created by HuCongshi on 15/11/15.
//  Copyright © 2015年 HuCongshi. All rights reserved.
//

#import "MonitorViewController.h"

@interface MonitorViewController ()

@property (nonatomic, strong) UITableView *warningTables;
@property (nonatomic, strong) UITextView  *warningText;

@end

@implementation MonitorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initItems];
    // Do any additional setup after loading the view.
}
- (void)initItems{
    CGRect rx = [UIScreen mainScreen].bounds;
    UIView *banner = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rx.size.width, 130)];
    banner.backgroundColor = [UIColor blueColor];
    [self.view addSubview:banner];
    
    UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake(5,5,176,126)];
    logo.image = [UIImage imageNamed:@"logo.png"];
    [self.view addSubview:logo];
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(180, 30, 500, 80)];
    title.text = @"云资源管理系统";
    title.textColor = [UIColor whiteColor];
    title.font = [UIFont systemFontOfSize:36];
    title.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:title];
    
    UIView *hLine = [[UIView alloc] initWithFrame:CGRectMake(rx.size.width*0.4, 130, 2, rx.size.height-230)];
    hLine.backgroundColor = [UIColor blueColor];
    [self.view addSubview:hLine];
    
    UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(rx.size.width*0.4, rx.size.height/2, rx.size.width/3.0*2, 2)];
    vLine.backgroundColor = [UIColor blueColor];
    [self.view addSubview:vLine];
    
    UILabel *warningInfo = [[UILabel alloc] initWithFrame:CGRectMake(10, 135, 200, 30)];
    warningInfo.textAlignment = NSTextAlignmentLeft;
    warningInfo.text = @"告警信息";
    warningInfo.textColor = [UIColor blackColor];
    warningInfo.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:warningInfo];
    
    UILabel *boradLabel = [[UILabel alloc] initWithFrame:CGRectMake(20+rx.size.width*0.4, 135, 200, 50)];
    boradLabel.textAlignment = NSTextAlignmentLeft;
    boradLabel.text = @"告警牌";
    boradLabel.textColor = [UIColor blackColor];
    boradLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:boradLabel];
    
    UILabel *detailedLabel = [[UILabel alloc] initWithFrame:CGRectMake(20+rx.size.width*0.4, rx.size.height/2+5, 200, 50)];
    detailedLabel.textAlignment = NSTextAlignmentLeft;
    detailedLabel.text = @"告警详情";
    detailedLabel.textColor = [UIColor blackColor];
    detailedLabel.font = [UIFont systemFontOfSize:24];
    [self.view addSubview:detailedLabel];
    
    //////////////////////////////////////////////////////////////
    self.warningTables = [[UITableView alloc] initWithFrame:CGRectMake(10, 165, rx.size.width*0.4-20, rx.size.height-270)];
    //self.warningTables.backgroundColor = [UIColor orangeColor];
    self.warningTables.scrollEnabled = NO;
    self.warningTables.delegate = self;
    self.warningTables.dataSource = self;
    [self.view addSubview:self.warningTables];
    
    self.warningText = [[UITextView alloc] initWithFrame:CGRectMake(20+rx.size.width*0.4, rx.size.height/2+55, rx.size.width*0.5, rx.size.height*0.5-165)];
    //self.warningText.backgroundColor = [UIColor orangeColor];
    self.warningText.editable = NO;
    self.warningText.scrollEnabled = YES;
    self.warningText.font = [UIFont systemFontOfSize:20];
    [self.view addSubview:self.warningText];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - UITableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 11;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    
    NSUInteger row = [indexPath row];
    cell.textLabel.text = [NSString stringWithFormat:@"告警:%lu",row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSUInteger row = [indexPath row];
    self.warningText.text = [NSString stringWithFormat:@"告警%lu详细信息:",row];
}
@end
